import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton } from '../Common/options'
import { OrganizationIdentityLevel } from '../Common/Conversion'

export const ProjectOperationPayment = async ({ url, OptionsEvent, ClientData, Permission }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'year@desc,month@desc' },
        get: API_LIST()[`get${url}OC`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === '35e6e69f-ea33-4250-ad8e-a7f6afafea96') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.tableName, title: '名称', width: 150 },
            {
                dataIndex: 'organizationUuid',
                title: '项目名称',
                valueType: 'select',
                valueEnum: await OrganizationIdentityLevel(4),
                rules: true,
                width: 450,
            },
            {
                dataIndex: 'yearMonth',
                title: '年月',
                valueType: 'Date',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'interestAmount',
                title: '滞纳金(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'loanPrincipalCopeAmount',
                title: '贷款本金应付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'loanPrincipalPaidAmount',
                title: '贷款本金已付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'loanInterestCopeAmount',
                title: '贷款利息应付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'loanInterestPaidAmount',
                title: '贷款利息已付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'capitalPrincipalCopeAmount',
                title: '资本金本金应付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'capitalPrincipalPaidAmount',
                title: '资本金本金已付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'capitalInterestCopeAmount',
                title: '资本金收益应付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'capitalInterestPaidAmount',
                title: '资本金收益已付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'operationFeeCopeAmount',
                title: '运营养护费应付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                dataIndex: 'operationFeePaidAmount',
                title: '运营养护费已付金额(万元)',
                valueType: 'inputNumber',
                hideInSearch: true,
                rules: true,
                width: 200,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 200,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '883ad1cb-70de-4e24-946a-0bfd9356aa94') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === 'd19d8804-3735-4d31-ae79-9a6513c21381') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
